package pkg.networking;
/**
 * BomberBoy, CPS240 Term Project - Team A
 * Andrew Osterink, David Bash, Scott Kidder
 * 
 *  Takes all actions executed on a player and sends them
 *  to the message pump system
 */
import pkg.Player;
import pkg.commands.ICommand;
import pkg.commands.PlayerCmd;
import pkg.commands.PlayerMoveCmd;

public class NetworkedPlayer extends Player {
	
	public static final int LOCALMODE = 0;
    public static final int REMOTEMODE = 1;
	
	private String name;
	private int currentMode = REMOTEMODE;
	public NetworkedPlayer()
	{
	}
	
	public void move(Direction direction,int speed)
	{
		super.move(direction, speed);
		sendCommand(PlayerCmd.move(getUserID(), direction, speed));
	
	}
	
	public void stop()
	{
		super.stop();
		PlayerMoveCmd cmd = PlayerCmd.move(getUserID(), this.curDirection, 0);
		cmd.setStop(true);
		sendCommand(cmd);
		
	}
	
	
	private void sendCommand(ICommand cmd)
	{
	 	if(currentMode == REMOTEMODE)
	 	   manager.getDistributor().execute(cmd);
	}
	
	public void mode(int mode)
	{
		currentMode = mode;
	}
	
	public int mode()
	{
		return currentMode;
	}
	
	public String getName()
	{
		return name;
	}
	
	public void setName(String newName)
	{
		name = newName;
	}
}
